package post.graduate.go.ready.experiment.nekohtml;

public class URLFactory {

	public static String UrlProcessFactory(String url, String actionUrl) {
		if (url == null || url.trim().length() <= 0)
			return null;
		if (actionUrl == null || actionUrl.trim().length() <= 0)
			return url;
		if (actionUrl.contains("://")) {
			return actionUrl;
		} else if (actionUrl.startsWith("/")) {
			int fromIndex = url.indexOf("//");
			int pos = url.indexOf("/", fromIndex + 2);
			return url.substring(0, pos) + actionUrl;
		} else {
			int pos = url.lastIndexOf("/");
			return url.substring(0, pos + 1) + actionUrl;
		}

	}

}
